package cn.edu.tsinghua.cic.ccss.web;

import javax.annotation.Resource;

import org.forten.core.ro.DtoResultWithPageInfo;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

import cn.edu.tsinghua.cic.ccss.bo.CourseSelectBo;
import cn.edu.tsinghua.cic.ccss.dto.CourseCanceledDto;
import cn.edu.tsinghua.cic.ccss.qo.CourseSelectionQo;

@Controller
@Scope("prototype")
@RequestMapping("selectcourse")
@SessionAttributes("courseSelectionQo")
public class CourseAction4QueryCanceledCourseAdmin {

	@Resource(name = "courseSelectionQo")
	private CourseSelectionQo courseSelectionQo;
	@Resource(name = "courseSelectBo")
	private CourseSelectBo courseSelectBo;

	@RequestMapping("gotoCourseCanceledByAdminList")
	public String gotoCourseCanceledByAdminList(Model model) {
		model.addAttribute("courseSelectionQo", courseSelectionQo);
		return "forward:showCourseCanceledByAdminList.jspx";
	}

	@RequestMapping("showCourseCanceledByAdminList")
	public String showCourseCanceledByAdminList(
			Model model,
			@ModelAttribute("courseSelectionQo") CourseSelectionQo courseSelectionQo,
			@RequestParam(defaultValue = "1") int pageNo) {
		DtoResultWithPageInfo<CourseCanceledDto> dtoList = this.courseSelectBo
				.queryCourseCanceled(courseSelectionQo, pageNo);
		model.addAttribute("dto", dtoList.getResults());
		model.addAttribute("page", dtoList.getPageInfo());
		model.addAttribute("courseSelectionQo", courseSelectionQo);
		return "selectcourse/gldxk_tkcx";
	}
}
